package com.findyou.service.impl;

import com.findyou.dao.UserDao;
import com.findyou.entity.User;
import com.findyou.service.UserService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.util.List;

/**
 * @Title: UserServiceImpl
 * @Author 贾金博
 * @Package com.findyou.service.impl
 * @Date 2024/11/15 上午9:25
 * @description: 实现类
 */
@Service // 相当于配置了Bean标签
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    /**
     * 根据id查询用户类
     * @param id
     * @return
     * @throws SQLException
     */
    @Override
    public User findUserById(int id) throws SQLException {
        return userDao.findUserById(id);
    }

    /**
     * 查询全部的用户
     * @return
     * @throws SQLException
     */
    @Override
    public List<User> findAllUsers() throws SQLException {
        return userDao.findAllUsers();
    }

    /**
     * 插入新的用户
     * @param user
     * @throws SQLException
     */
    @Override
    public void insertUser(User user) throws SQLException {
        userDao.insertUser(user);
    }

    /**
     * 根据id删除用户
     * @param id
     * @throws SQLException
     */
    @Override
    public void deleteUser(int id) throws SQLException {
        userDao.deleteUser(id);
    }

    /**
     * 更新用户的信息
     * @param user
     * @throws SQLException
     */
    @Override
    public void updateUser(User user) throws SQLException {
        userDao.updateUser(user);
    }

}
